<template>
  <page-header-wrapper>
    <template v-slot:content>
      
    </template>
    <template v-slot:extraContent>
      <div class="extra-content">
        <!-- <div class="stat-item" v-if="role_id==2">
          <a-statistic title="我的佣金" :value="fans_num" />
        </div> -->
        <div class="stat-item">
          <a-statistic title="我的供应商数量" :value="fin_num"/>
        </div>
        <div class="stat-item">
          <a-statistic title="我的商户数量" :value="wei_num"/>
        </div>
      </div>
    </template>

    <!-- <div>
      <a-row :gutter="24">

        <a-col :xl="16" :lg="24" :md="24" :sm="24" :xs="24">
          <a-card
            class="project-list"
            :loading="loadings"
            style="margin-bottom: 24px;"
            :bordered="false"
            title="进行中的活动"
            :body-style="{ padding: 0 }">
            <a slot="extra" @click="handleJump">全部活动</a>
            <div>
              <a-card-grid class="project-card-grid" :key="i" v-for="(item, i) in crList">
                <a-card :bordered="false" :body-style="{ padding: 0 }">
                  <a-card-meta>
                    <div slot="title" class="card-title">
                      <a-avatar size="small" :src="item.cover"/>
                      <a @click="handleJump">{{ item.title }}</a>
                    </div>
                    <div slot="description" class="card-description">
                      {{ item.merchantname }}
                    </div>
                  </a-card-meta>
                  <div class="project-item">
                    <a href="/#/">{{item.createtime}}</a>
                    <span class="datetime">{{item.end_time}}</span>
                  </div>
                </a-card>
              </a-card-grid>
            </div>
          </a-card>

          <a-card :loading="loadings1" title="动态" :bordered="false" >
            <a slot="extra" @click="handleJumpVip">全部订单</a>
            <a-list>
              <a-list-item :key="index" v-for="(item, index) in vipList">
                <a-list-item-meta>
                  <a-avatar slot="avatar" :src="item.avatar"/>
                  <div slot="title">
                    <span>{{ item.nickname }}</span>&nbsp;
                    在&nbsp;<a href="#">{{ item.SHname }}</a>&nbsp;
                    <span>购买了</span>&nbsp;
                    <a href="#">{{ item.Mealname }}</a>
                  </div>
                  <div slot="description">{{ item.createtime }}</div>
                </a-list-item-meta>
              </a-list-item>
            </a-list>
          </a-card>
        </a-col>
          <a-col style="padding: 0 12px"
          :xl="8"
          :lg="24"
          :md="24"
          :sm="24"
          :xs="24">
            <a-col>
              <a-card :bordered="false" style="margin-bottom: 24px;">
                <div ref="myChart" :style="{width: '100%', height: '300px'}"></div>
              </a-card>
            </a-col>
          <a-card>
            <a-tabs default-active-key="1" @change="callback">

            <a-tab-pane key="1" tab="增长商户数" force-render>
              <a-col>
                <a-card :bordered="false">
                <div ref="myChart2" :style="{width: '100%', height: '380px'}"></div>
                </a-card>
              </a-col>
            </a-tab-pane>

            <a-tab-pane key="2" tab="增长活动数" force-render>
              <a-col>
                <a-card :bordered="false">
                  <div ref="myChart3" :style="{width: '100%', height: '380px'}"></div>
                </a-card>
              </a-col>
            </a-tab-pane>
            </a-tabs>
          </a-card>
        </a-col>
      </a-row>
    </div> -->
  </page-header-wrapper>
</template>

<script>
// import * as echarts from 'echarts';
let echarts = require('echarts')
import { PageHeaderWrapper } from '@ant-design-vue/pro-layout'
import { Radar } from '@/components'
// import { GetActcount, GeMerchant, getFans, getMerchantCount, getHDcount, getSelplay, getActivitySelplay, getVIPLIft, getPcSystem } from '../../api/umisystem'

export default {
  name: 'ymiwelIndex',
  components: {
    PageHeaderWrapper,
    Radar
  },
  data () {
    return {
      logo: '',
      title: '',
      loadings1: true,
      // 商家列表
      vipList: [],
      loadings: true,
      // 列表
      crList: [],
      // 用户信息
      fin_num: 0,
      wei_num: 0,
      fans_num: 0,
      loading: true,
      activities: [],
      role_id:'',
    }
  },
  created () {
    // console.log('login-------+++++')
    // this.login();
    // console.log('loginend-------+++++')
    // getPcSystem().then(res => {
    //   console.log('系统设置',res)
    //   this.title = res.data.value.title
    //   this.logo = res.data.value.logo
    // })
    // getFans().then(res => {
    //   this.fans_num = res.data
    // })
    // getMerchantCount().then(res => {
    //   this.wei_num = res.data
    // })
    // getHDcount().then(res => {
    //   this.fin_num = res.data
    // })
    // getActivitySelplay().then(res => {
    //   console.log('res', res)
    //   this.loadings = false
    //   this.crList = res.data
    // })
    // getVIPLIft().then(res => {
    //   console.log('------------------------', res)
    //   this.vipList = res.data.data.slice(0, 6)
    //   this.loadings1 = false
    // })
    
  },
  mounted () {
    this.role_id = localStorage.getItem('role_id')
    console.log('workplace')
    // this.drawLine();
    // this.drawLine2();
    // this.drawLineList();
  },
  methods: {
    handleJumpVip() {
      this.$router.push({path: '/ymivip/vipbill/index'})
    },
    handleJump() {
      this.$router.push({name: 'modelCopy'})
    },
    callback(key) {
      console.log(key);
    },
    drawLine(){
      // 基于准备好的dom，初始化echarts实例
      // let myChart = echarts.init(document.getElementById('myChart'))
      let bar_dv = this.$refs.myChart
      if(bar_dv) {
      let myChart = echarts.init(bar_dv)
      // 绘制图表
      GetActcount().then(res => {
        const xData = []
        const yData = []
        for(let i = 0; i < res.data.length; i++) {
          if(i % 2 === 0) {
            xData.push(res.data[i])
         } else {
           yData.push(res.data[i])
          }
        }
        myChart.setOption({
           grid:{
            top:"10px",
            left:"25px",
            right:"70px",
            bottom:"44px"
	        },
          color: ['#D35400'],
          tooltip: {},
          xAxis: {
            data: xData,
            axisLabel: { interval: 0, rotate: 30 },
          },
          yAxis: {},
          series: [{
            name: '增长数',
            type: 'line',
            data: yData
          }]
      });
      })
      }
    },

    drawLine2(){
      // 基于准备好的dom，初始化echarts实例
      // let myChart2 = echarts.init(document.getElementById('myChart2'))
      let bar_dv = this.$refs.myChart2
      if(bar_dv) {
      let myChart2 = echarts.init(bar_dv)
      // 绘制图表
      GeMerchant().then(res => {
        const xData = []
        const yData = []
        for(let i = 0; i < res.data.length; i++) {
          if(i % 2 === 0) {
            xData.push(res.data[i])
         } else {
           yData.push(res.data[i])
          }
        }
        myChart2.setOption({
          color: ['#8E44AD'],
          tooltip: {},
          xAxis: {
            data: xData,
            axisLabel: { interval: 0, rotate: 30 },
          },
          yAxis: {},
          series: [{
            name: '增长数',
            type: 'bar',
            data: yData
          }]
      });
      })
      }
    },
    drawLineList(){
      // 基于准备好的dom，初始化echarts实例
      // let myChart3 = echarts.init(document.getElementById('myChart3'))
      let bar_dv = this.$refs.myChart3
      if(bar_dv) {
        let myChart3 = echarts.init(bar_dv)
        // 绘制图表
        getSelplay().then(res => {
          const xData = []
          const yData = []
          for(let i = 0; i < res.data.length; i++) {
            if(i % 2 === 0) {
              xData.push(res.data[i])
          } else {
            yData.push(res.data[i])
            }
          }
          myChart3.setOption({
            color: ['#37A2FF', '#FF0087', '#FFBF00'],
            tooltip: {},
            xAxis: {
              data: xData,
              axisLabel: { interval: 0, rotate: 30 },
            },
            yAxis: {},
            series: [{
              name: '增长数',
              type: 'bar',
              data: yData
            }]
          });
        }, reason => {
        })
      }
    }
  }
}
</script>

<style lang="less" scoped>
  @import "./Workplace.less";
  .content{
    display: inline-block;
    width: 400px;
  }
  .right{
    display: inline-block;
    width: 400px;
  }
  .left{
    display: inline-block;
    width: 400px;
  }
  .project-list {

    .card-title {
      font-size: 0;

      a {
        color: rgba(0, 0, 0, 0.85);
        margin-left: 12px;
        line-height: 24px;
        height: 24px;
        display: inline-block;
        vertical-align: top;
        font-size: 14px;

        &:hover {
          color: #1890ff;
        }
      }
    }

    .card-description {
      color: rgba(0, 0, 0, 0.45);
      height: 44px;
      line-height: 22px;
      overflow: hidden;
    }

    .project-item {
      display: flex;
      margin-top: 8px;
      overflow: hidden;
      font-size: 12px;
      height: 20px;
      line-height: 20px;

      a {
        color: rgba(0, 0, 0, 0.45);
        display: inline-block;
        flex: 1 1 0;

        &:hover {
          color: #1890ff;
        }
      }

      .datetime {
        color: rgba(0, 0, 0, 0.25);
        flex: 0 0 auto;
        float: right;
      }
    }

    .ant-card-meta-description {
      color: rgba(0, 0, 0, 0.45);
      height: 44px;
      line-height: 22px;
      overflow: hidden;
    }
  }

  .item-group {
    padding: 20px 0 8px 24px;
    font-size: 0;

    a {
      color: rgba(0, 0, 0, 0.65);
      display: inline-block;
      font-size: 14px;
      margin-bottom: 13px;
      width: 25%;
    }
  }

  .members {
    a {
      display: block;
      margin: 12px 0;
      line-height: 24px;
      height: 24px;

      .member {
        font-size: 14px;
        color: rgba(0, 0, 0, .65);
        line-height: 24px;
        max-width: 100px;
        vertical-align: top;
        margin-left: 12px;
        transition: all 0.3s;
        display: inline-block;
      }

      &:hover {
        span {
          color: #1890ff;
        }
      }
    }
  }

  .mobile {

    .project-list {

      .project-card-grid {
        width: 100%;
      }
    }

    .more-info {
      border: 0;
      padding-top: 16px;
      margin: 16px 0 16px;
    }

    .headerContent .title .welcome-text {
      display: none;
    }
  }

</style>
